from manim import *



class math1(MovingCameraScene):
    def construct(self):
        self.camera.background_color = BLACK  # 设置背景颜色
        self.camera.frame_width = 100  # 设置边框宽度
        self.camera.frame_height = 60  # 设置边框高度
        self.camera.pixel_height = 1080  # 设置像素高度
        self.camera.pixel_width = 1920  # 设置像素宽度
        self.camera.center = ORIGIN  # 设置中心点位置
        self.camera.scale_factor = 1.0  # 设置缩放因子
        #设置横线
        for i in range(6*2+1):       
            dot1=Dot([-50,5*(i-6),0]).set_opacity(0.5)
            dot2=Dot([50,5*(i-6),0]).set_opacity(0.5)
            if i==6:
                line1=Line(dot1,dot2).set_color(WHITE).set_opacity(0.5)
                
            else:
                line1=Line(dot1,dot2).set_color(WHITE).set_opacity(0.5)
               
            self.add(dot1,dot2,line1)
        #设置竖线
        for i in range(10*2+1):        
            dot3=Dot([(i-10)*5,-30,0]).set_opacity(0.5)
            dot4=Dot([(i-10)*5,30,0]).set_opacity(0.5)
            if i==10:
                line2=Line(dot3,dot4).set_color(WHITE).set_opacity(0.5)
                
            else:
                line2=Line(dot3,dot4).set_color(WHITE).set_opacity(0.5)
            self.add(dot3,dot4,line2)
        #设置三个点
        dot1 = Dot(radius=1, color=RED)  
        dot1.move_to([-47.5,27.5,0]) 
        dot2 = Dot(radius=1, color=YELLOW)  
        dot2.move_to([-42.5,27.5,0])  
        dot3 = Dot(radius=1, color=GREEN)  
        dot3.move_to([-37.5,27.5,0])
        #镜头跟进效果 
        self.camera.frame.save_state()
        #题目出现
        text0 = Tex(r"\text{(张1)设}$x\geq 0,y\geq 0$\text{,曲线}$L_{1}:x^{2}+y^{2}-xy=1,L_{2}:x^{2}+y^{2}-xy=2$"
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).move_to([0,20,0])
        text00= Tex(r"\text{,直线}$L_{3}:y=\dfrac{\sqrt{3}}{3}x,L_{4}:y=\sqrt{3}x$"
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).next_to(text0,DOWN,buff=1)
        text1 = Tex(
                   r"\text{区域}$D$\text{由}$L_{1},L_{2},L_{3},L_{4}$\text{围成}"
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).next_to(text00,DOWN,buff=1)
        text2 = Tex(
                    r"\text{(张2)已知曲线}$L$\text{的极坐标方程为}$r=\sin 3\theta \left( 0\leq \theta \leq \dfrac{\pi }{3}\right) $\text{,}"
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).move_to([0,0,0])
        text20 = Tex(
                    r"$D$\text{为曲线}$L$\text{围成的区域}"
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).next_to(text2,DOWN,buff=1)
        text3 = Tex(
                   r"\text{(张3)已知平面区域}$D=\left\{  \left( x,y\right) \left| \right| x| \leq y,\left( x^{2}+y^{2}\right) ^{3}\leq y^{4}\right\} $"
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).move_to([0,-15,0])
        

        self.play(Write(text0),Write(text00),Write(text1),Write(text2),Write(text20),Write(text3))

        #镜头拉回
          #分析文本
        #text100=MarkupText("<b><i>分析/解：</i></b>",color=PINK).scale(5.0).move_to([-38,12.5,0])
        self.play(FadeIn(dot1),run_time=0.1)
        self.play(FadeIn(dot2),run_time=0.1)
        self.play(FadeIn(dot3),run_time=0.1)
        

        self.wait()